home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
c
/
AmiVoGL_MDEV.lha
/
drivers
/
amiga.c
next >
Wrap
C/C++ Source or Header
|
1994-12-19
|
38KB
|
1,305 lines
/*
* Vogle driver for the Amiga
*
* Written By: Dr. Charles E. Campbell, Jr.
* Version : 1.00
* Date : September 28, 1993
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
#include <functions.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include <graphics/rastport.h>
#include <graphics/gfxmacros.h>
#include <graphics/text.h>
#include <exec/memory.h>
#include <devices/inputevent.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/console_protos.h>
#include "vogl.h"
#define INTUITION_REV ((unsigned long) 33L)
#define GRAPICS_REV ((unsigned long) 33L)
/* --------------------------------------------------------------------------
* Definitions Section:
*/
#define SNGLBUFMODE 0 /* default scrbufmode value */
#define DBLBUFMODE 1 /* scrbufmode value */
#define RAWKEYBUF 128 /* initial size of rawkey buffer conversion */
#define KEYBUF 256 /* max size of keybuffer to be read */
#define FONTSEP ';'
#define MAXVRTX 200
#define MAXSTRING 1024
#ifdef SASC
#define USESVMODE
#endif
#ifdef AZTEC_C
# define MEMTYPE (MEMF_CHIP|MEMF_CLEAR)
#else
# define MEMTYPE (MEMF_CLEAR)
#endif
/* head_link: handles the generation of head-linked lists. Note that
* each structure is assumed to have the member "nxt".
* The new member becomes "head" - ie. oldest is last in the linked list,
* the newest is first.
*/
#define head_link(structure,head,fail_msg) { \
structure *newstr; \
newstr= (structure *) malloc(sizeof(structure)); \
if(!newstr) printf("***out of memory*** <%s>\n",fail_msg); \
newstr->nxt= head; \
head = newstr; \
}
/* stralloc: allocates new memory for and copies a string into the new mem */
#define stralloc(ptr,string,fail_msg) { \
ptr= (char *) calloc((size_t) strlen(string) + 1,sizeof(char)); \
if(!ptr) printf("***out of memory*** <%s>\n",fail_msg); \
strcpy(ptr,string); \
}
/* --------------------------------------------------------------------------
* Typedefs:
*/
typedef struct FontList_str FontList;
/* --------------------------------------------------------------------------
* Data Structures:
*/
struct FontList_str {
char *fontspec;
struct TextFont *textfont;
FontList *nxt;
};
/* --------------------------------------------------------------------------
* Extern Data:
*/
#ifdef AZTEC_C
extern int Enable_Abort;
#else
void __regargs __checkabort (void);
#endif
/* --------------------------------------------------------------------------
* Local Data:
*/
WORD *voglareaBuffer= NULL;
struct BitMap *voglback = NULL;
struct BitMap *voglfront = NULL;
struct DiskFontBase *DiskfontBase = NULL;
struct GfxBase *GfxBase = NULL;
struct IntuiText *voglitext = NULL;
struct IntuitionBase *IntuitionBase = NULL;
struct IOStdReq *vogl_cd_ioreq = NULL;
struct Library *ConsoleDevice = NULL;
struct RastPort *voglrastport = NULL;
struct Screen *voglscreen = NULL;
struct TextAttr *vogltextattr = NULL;
struct TmpRas *vogltmpras = NULL;
struct Window *voglwindow = NULL;
static char useborder = 0;
static char scrbufmode = SNGLBUFMODE;
static char *rawkeybuf = NULL;
static int grfxmode = 0;
static int currcolor = 0;
static UBYTE *voglstring = NULL;
static UWORD scrdepth = 4;
static UWORD scrwidth = 0;
static UWORD scrheight = 0;
static UWORD voglscrbordleft = 0;
static UWORD voglscrbordright= 0;
static UWORD voglscrbordtop = 0;
static UWORD voglscrbordbttm = 0;
static USHORT screenviewmode = HIRES|LACE;
static LONG qtyrawkeybuf = 0L;
static FontList *fontlisthd = NULL;
static struct InputEvent *voglievent = NULL;
static PLANEPTR voglplaneptr = NULL;
/* voglkeybuf
* |uuuddddddduuuuu| u=unused d=data
* ^ ^
* ikeybgn ikeyend (always point to unused)
*/
static char voglkeybuf[KEYBUF];
static unsigned ikeyend= 0; /* points just-past chars in voglkeybuf */
static unsigned ikeybgn= KEYBUF-1; /* points just-before chars in voglkeybuf */
/* --------------------------------------------------------------------------
* Local Prototypes:
*/
void AMIGA_config(char *); /* amiga.c */
int AMIGA_init(void); /* amiga.c */
static struct BitMap *makeBitMap(void); /* amiga.c */
void freeBitMap(struct BitMap *); /* amiga.c */
int AMIGA_exit(void); /* amiga.c */
void AMIGA_draw( int, int); /* amiga.c */
int AMIGA_getkey(void); /* amiga.c */
int AMIGA_checkkey(void); /* amiga.c */
int AMIGA_locator( int *, int *); /* amiga.c */
void AMIGA_clear(void); /* amiga.c */
void AMIGA_color(int); /* amiga.c */
void AMIGA_mapcolor( int, int, int, int); /* amiga.c */
int AMIGA_font(char *); /* amiga.c */
void AMIGA_char(char); /* amiga.c */
void AMIGA_string(char *); /* amiga.c */
void AMIGA_fill( int, int[], int[]); /* amiga.c */
int AMIGA_backbuffer(void); /* amiga.c */
int AMIGA_swapbuffer(void); /* amiga.c */
void AMIGA_frontbuffer(void); /* amiga.c */
void _AMIGA_devcpy(void); /* amiga.c */
/* --------------------------------------------------------------------------
* Device Entry
* fontname;height[;{BEIPU}]
* B == bold
* E == extended
* I == italic
* P == plain (default)
* U == underlined
*/
static DevEntry amigadev = {
"AMIGA", /* name of device */
"topaz;9;P", /* name of small "hardware" font */
"topaz;11;P", /* name of large "hardware" font */
AMIGA_backbuffer, /* initializes double buffering */
AMIGA_char, /* prints a "hardware" character */
AMIGA_checkkey, /* check if keyboard key hit, return it */
AMIGA_clear, /* clears viewport to background */
AMIGA_color, /* change current color index */
AMIGA_draw, /* draws line from current to (x,y) */
AMIGA_exit, /* cleans up and allows vogle to exit */
AMIGA_fill, /* does filled polygons */
AMIGA_font, /* sets up a hardware font */
AMIGA_frontbuffer, /* switches drawing into front buffer */
AMIGA_getkey, /* gets a char of input */
AMIGA_init, /* enables graphics */
AMIGA_locator, /* finds mouse position in vogle device coords */
AMIGA_mapcolor, /* changes color at index to given rgb value */
AMIGA_string, /* prints a string of hardware text */
AMIGA_swapbuffer}; /* swaps front and back buffers */
/* ==========================================================================
* Source Code:
*/
/* AMIGA_config: This function modifies what AMIGA_init does. It allows the
* user to control the type of screen and bitmaps used. Note that one may
* use extra half-brite mode, too. I put in ham mode since I expect to
* attempt to do some shading someday.
*
* The AMIGA_init sets up a gimmezerozero window using a custom Screen and
* BitMap.
*
* The config string may include:
* b : use border&title on window
* d : double buffer mode
* e : extra halfbrite mode
* h : ham graphics mode
* s : s